#ifndef BASELAYOUT_H
#define BASELAYOUT_H
#include "EditorCamera.h"
#include "StompedReality/Core/GameAccess.h"
#include "StomperLib/Controls/NewProject.h"
#include "StomperLib/ToolModel.h"
#include <Gwen/Controls/MenuStrip.h>
#include <Gwen/Controls/WindowControl.h>
#include <Gwen/Gwen.h>
namespace StomperLib {
namespace Controls {
class ToolWindow;
}
class ToolElement;

class BaseLayout : public Gwen::Controls::Base, public StompedReality::GameAccess
{
 protected:

  bool m_MouseInEditorArea;
  StomperLib::Controls::NewProject* m_NewProject;
  Gwen::Controls::MenuStrip* m_MenuStrip;
  Gwen::Controls::MenuItem* m_WindowMenu;
  StompedReality::JsonPTR m_EditorProperties;
  std::vector<StomperLib::ToolElement*> m_Elements;

  StomperLib::EditorCamera* m_Camera;

  // create gui
  Gwen::Controls::MenuItem* CreateSubWindowMenuItem( Gwen::String title, Gwen::String accelerator, bool toggled );

  void CreateMenuStrip( );

  void CreateNewProjectOverlay( );

 public:

  //! \brief	Constructor.
  BaseLayout( Gwen::Controls::Canvas* canvas );

  //! \brief	Destructor.
  virtual ~BaseLayout( );

  //! \brief	Creates Base Elements.
  //!			Must be called after set game
  //!			Creates :
  //!				- Menu strip
  //!				- New project dialog
  void CreateBaseElements( );

  //! \brief	Called after base elements are created.
  virtual void OnCreateBaseElements( ) {
  };

  StomperLib::Controls::ToolWindow* CreateSubWindow( Gwen::String title, Gwen::String accelerator = "",
                                                     bool toggled = true );

  void Render( Gwen::Skin::Base* skin );
  void AddToolElement( StomperLib::ToolElement* element );

  // events
  Gwen::Event::Caller onCreateProject;
  Gwen::Event::Caller onOpenProject;
  Gwen::Event::Caller onSaveProject;
  Gwen::Event::Caller onMouseEditAreaEnter;
  Gwen::Event::Caller onMouseEditAreaLeave;

 private:

  void OnCreateProjectClick( );
  void OnSaveLayoutClick( );
  void OnOpenProjectClick( );
  void OnSaveProjectClick( );
  void OnCreateProject(  Gwen::Event::Info info );
  void OpenProject( Gwen::String projectFile );
  void OpenDialogCallback( Gwen::Event::Info info );
  void OnMouseEditAreaEnter( );
  void OnMouseEditAreaLeave( );
  void OnWindowToggleChange(  Gwen::Event::Info info );
  void OnWindowCloseClick(  Gwen::Event::Info info );

 private:

  void LoadLayout( );

 public:

  ToolModel* Model;
};

}
#endif // ifndef BASELAYOUT_H